<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>编辑供应商帐号</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link rel="stylesheet" href="admin/css/common.css" type="text/css" />
<link rel="stylesheet" href="admin/css/provider.css" type="text/css" />
<script type="text/javascript" src="admin/js/province-city.js"></script>
<script type="text/javascript" src="js/jquery-1.7.1.js"></script>
<script type="text/javascript">
	//判断是否为空
	function check() {

		$('#nameTip').text("");
		$('#pwdTip').text("");
		$('#pwdChkTip').text("");

		if ($('#name').val() == "") {
			$('#nameTip').text("*用户名不能为空");
			$('#name').focus();
			return false;
		} else if ($('#nameFlag').val() != "yes") {
			$('#nameTip').text("*用户名已经存在");
			$('#name').focus();
			return false;
		} else if($('#password').val() =="" ){
			$('#oldTip').text("");
			$('#pwdTip').text("*请输入新密码");
			$('#pwdChkTip').text("");
			$('#password').focus();
			return false;
		}else if($('#password').val() != $('#passwordChk').val()){
			$('#oldTip').text("");
			$('#pwdTip').text("");
			$('#pwdChkTip').text("*两次新密码不相同");
			$('#passwordChk').focus();
			return false;
		}
		return true;
	}

	function checkUsername() {
		$('#nameFlag').val("no");
		if ($("#name").val() != "") {
			var params = {
				providerName : $("#name").val(),
				flag : "update",
				providerId : $('#providerId').val()
			};
			jQuery.post("checkUsernameExist.action", params, callbackFunc, "json");
		}
	}
	function callbackFunc(data) {
		if (data.existFlag != 0) {
			$('#nameTip').html('<font color="red">*名字已经存在</font>');
			$('#nameFlag').val("no");
		} else {
			$('#nameTip').html('<font color="green">名字可以使用</font>');
			$('#nameFlag').val("yes");
		}
	}

</script>
</head>
<body>
	<div id="provider_zone">
		<form action="provider/updateProvider.action?type=account" method="post"
			enctype="multipart/form-data" onsubmit="return check();">
			<table width="99%" border="0" align="center" cellpadding="3"
				cellspacing="1" class="table_style">
				<tr>
					<td class="left_title_1">供应商名字</td>
					<td>
						${provider.name }
					</td>
				</tr>
				<tr>
					<td class="left_title_2">用户名</td>
					<td><input type="text" name="provider.username" id="name"
						value="${provider.username }" onblur="checkUsername()" /> <span
						class="tip" id="nameTip"></span> <input type="hidden"
						id="nameFlag" value="yes" />
					</td>
				</tr>
				<tr>
			      <td class="left_title_1">新密码</td>
			      <td>
			      	<input type="password" id="password" name="provider.password" />
			      	<span class="tip" id="pwdTip"></span>
			      </td>
			    </tr>
			    <tr>
			      <td class="left_title_2">新密码确认</td>
			      <td>
			      	<input type="password" id="passwordChk" name="passwordChk" />
			      	<span class="tip" id="pwdChkTip"></span>
			      </td>
			    </tr>
				<tr>
					<td colspan="2" style="padding-left: 530px;"><input
						type="submit" class="input-submit" value="修改" /> <input
						type="hidden" value="${providerId }" name="providerId"
						id="providerId" /> <input type="hidden" value="${providerId }"
						name="provider.id" />
					</td>
				</tr>

			</table>
		</form>
	</div>
</body>
</html>
